package com.hserver.beetlsql.action;

import com.hserver.beetlsql.bean.User;
import com.hserver.beetlsql.service.UserService;
import top.hserver.core.ioc.annotation.Autowired;
import top.hserver.core.ioc.annotation.Controller;
import top.hserver.core.ioc.annotation.GET;
import top.hserver.core.server.util.JsonResult;

import java.util.List;

@Controller
public class IndexAction {

    @Autowired
    private UserService userService;

    @GET("/update")
    public JsonResult update() {
        userService.update();
        return JsonResult.ok();
    }


    @GET("/select")
    public JsonResult select() {
        List<User> select = userService.select();
        return JsonResult.ok().put("data",select);
    }



    @GET("/add")
    public JsonResult add() {
        if (userService.add()){
            return JsonResult.ok();
        }
        return JsonResult.error();
    }

}
